package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.pojo.user.gift.ChargeUserGift;
import com.zhentao.service.ChargeUserGiftService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth/user")
public class ChargeUserGiftController {
    @Autowired
    private ChargeUserGiftService chargeUserGiftService;

    @GetMapping("/gift/getGifts")
    public ResponseResult getGifts() {
        return chargeUserGiftService.getGifts();
    }

    @GetMapping("/gift/addGift")
    public ResponseResult addGift(@RequestParam("id") Integer id) {

        return chargeUserGiftService.addGift(id);
    }

    @GetMapping("/gift/getUserGifts")
    public ResponseResult getUserHistoryGift() {
        return chargeUserGiftService.getUserHistoryGift();
    }


    @GetMapping("/gift/exchangeGoods")
    public ResponseResult exchangeGoods(@RequestParam("giftId") Integer giftId) {
        return chargeUserGiftService.exchangeGoods(giftId);
    }

    @PostMapping("/gift/saveGift")
    public ResponseResult saveGift(@RequestBody(required = false) ChargeUserGift gift) {
        return chargeUserGiftService.saveGift(gift);
    }

    @PostMapping("/updateGift")
    public ResponseResult updateGift(@RequestBody ChargeUserGift gift) {
        return chargeUserGiftService.updateGift(gift);
    }

    @PostMapping("/{id}")
    public ResponseResult deleteGift(@PathVariable("id") Integer id) {
        return chargeUserGiftService.deleteGift(id);
    }
}
